<template>
	<view>
		<!-- 作废 -->
		<u-modal :show="zfVisible" title="提示" content='此操作将废弃该合同, 是否继续?' confirmColor="#3B75FF" @close="close('zf')"
			@cancel="close('zf')" @confirm="zfSubmit" showCancelButton closeOnClickOverlay></u-modal>
	</view>
</template>

<script>
	export default {
		name: "contractManagement",
		props: {
			value: {
				type: String,
				default: ''
			},
			oper_item: {
				type: Object,
				default: {}
			}
		},
		data() {
			return {
				// 作废
				zfVisible: false,
			};
		},
		watch: {
			value(val) {
				console.log(val, 'xxxx');
				switch (val) {
					case 'contract_contractInvalidation':
						this.zfVisible = true;
						break;
				}
			}
		},
		methods: {
			close(type) {
				switch (type) {
					case 'zf':
						this.zfVisible = false;
						break;
				}
				this.$emit('update:value', '');
			},

			/********** 合同作废 **********/
			zfSubmit() {
				uni.showLoading({
					mask: true
				});
				let oper_item = this.oper_item
				this.$hApi.contractInvalidation({
					id: oper_item.id,
					type: oper_item.contract_type,
				}).then(res => {
					console.log(res, 'contractInvalidation');
					uni.hideLoading();
					if (res.code == 200) {
						this.$emit('submit', this.value);
						this.close('zf')
					}
					uni.showToast({
						title: res.code == 200 ? "操作成功" : res.message,
						icon: res.code == 200 ? "success" : "error",
					});
				})
			},
		},
	}
</script>

<style>

</style>